<template>
  <view class="withdrawalHistory">
    <topTitle title="充值紀錄" />
    <view class="com">
      <view class="orderList">
        <view v-for="(item, idx) in UserRechargeOrderList" :key="idx">
          <view>
            <view>
              {{ item.recharge_type == 1 ? "网银转账" : "快捷支付" }}
            </view>
            <view
              ><text>+{{ item.money }}</text></view
            >
          </view>
          <view>{{ formattingTime(item.add_time, 0) }} </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { UserRechargeOrder } from "@/api/UserApi";
import { onReachBottom } from "@dcloudio/uni-app";

let select_time: any = null;
let UserRechargeOrderList = ref<Array<any>>([]);

const UserRechargeOrderFn = async () => {
  let list = await UserRechargeOrder({
    select_time,
  });
  if (!select_time) {
    UserRechargeOrderList.value = list;
  } else {
    UserRechargeOrderList.value = [...UserRechargeOrderList.value, ...list];
  }
};

UserRechargeOrderFn();

onReachBottom(() => {
  select_time =
    UserRechargeOrderList.value[UserRechargeOrderList.value.length - 1]
      .add_time;
  UserRechargeOrderFn();
});
</script>
<style scoped lang="scss">
@import "../../static/scss/myWallet.scss";
</style>
